#delimit;
clear;
set more off;

global temp /Sastemp;
global path ~;
set mem 5000m;

capture log close;
log using $path/pollution/logfiles/basins.log, replace;

/*================================================
 Program: olsregs_alt.do
 Author:  Avi Ebenstein
 Created: August 2007
 Purpose: Census tabulations by county. Take them and
          send them to GIS.
=================================================*/

use ~/pollution/datafiles/dsp_basins.dta, replace;

global controls "yrsed farmer urban lnairpollution i.region i.cla3";

gen lncancer_rate=ln(cancer_o);
gen lndeathrate9=ln(deathrate9);
     
for any 090 091 095: gen lndeathrate_X=ln(deathrate_X);
for any 090 091 095: replace lndeathrate_X=0 if lndeathrate_X==.;

gen rounded_q=floor(overall_q);
gen rq=.;
replace rq=1 if rounded_q==1|rounded_q==2;
replace rq=2 if rounded_q==3|rounded_q==3;
replace rq=3 if rounded_q==4|rounded_q==5|rounded_q==6;

xi: reg lndeathrate9 i.rq [w=totalpop],cluster(provgb) robust;
outreg2 using ~/pollution/outfiles/olsregs_step.out,replace  se bdec(3) tdec(3);
xi: reg lndeathrate_090 i.rq [w=totalpop],cluster(provgb) robust;
outreg2 using ~/pollution/outfiles/olsregs_step.out,append  se bdec(3) tdec(3);
xi: reg lndeathrate_091 i.rq [w=totalpop],cluster(provgb) robust;
outreg2 using ~/pollution/outfiles/olsregs_step.out,append  se bdec(3) tdec(3);
xi: reg lndeathrate_095 i.rq [w=totalpop],cluster(provgb) robust;
outreg2 using ~/pollution/outfiles/olsregs_step.out,append  se bdec(3) tdec(3);

xi: reg lndeathrate9 i.rq $controls [w=totalpop],cluster(provgb) robust;
outreg2 using ~/pollution/outfiles/olsregs_step.out,append  se bdec(3) tdec(3);
xi: reg lndeathrate_090 i.rq $controls [w=totalpop],cluster(provgb) robust;
outreg2 using ~/pollution/outfiles/olsregs_step.out,append  se bdec(3) tdec(3);
xi: reg lndeathrate_091 i.rq $controls [w=totalpop],cluster(provgb) robust;
outreg2 using ~/pollution/outfiles/olsregs_step.out,append  se bdec(3) tdec(3);
xi: reg lndeathrate_095 i.rq $controls [w=totalpop],cluster(provgb) robust;
outreg2 using ~/pollution/outfiles/olsregs_step.out,append  se bdec(3) tdec(3);

type ~/pollution/outfiles/olsregs_step.out;

exit;
